import 'package:flutter/material.dart';
import '../../models/order_list_model.dart';
import '../../manger/cached_image_widget.dart';
import '../../l10n/app_localizations.dart';
class PayCellView extends StatelessWidget {
  final PayListModel model;
  final bool isSelected;
  final VoidCallback onTap;
  final VoidCallback onShowAuthTips;

  const PayCellView({
    super.key,
    required this.model,
    required this.isSelected,
    required this.onTap,
    required this.onShowAuthTips,
  });

  @override
  Widget build(BuildContext context) {
    bool showAuthTips = model.shopPaymentId == 56 && isSelected;
    return InkWell(
      onTap: model.status != 2 ? onTap : null,
      child: Container(
        height: 90,
        padding: const EdgeInsets.symmetric(horizontal: 15),
        decoration: BoxDecoration(
          color: Colors.white,
        ),
        child: Column(
          children: [
            Expanded(
              child: Row(
                crossAxisAlignment: CrossAxisAlignment.center,
                children: [
                  Container(
                    width: 120,
                    height: 60,
                    child: Stack(
                      alignment: Alignment.center,
                      children: [
                        CachedImage(
                          imageUrl: model.pic,
                          fit: BoxFit.cover,
                          height: 60,
                          width: 120,
                        ),
                        if (model.status == 2)
                        Container(
                          width: double.infinity,
                          height: double.infinity,
                          color: Colors.white.withValues(alpha: 0.6), // 半透明白色蒙层
                        ),
                        // 当model.status == 2时显示维护图片
                        if (model.status == 2)
                          Image.asset(
                            'assets/images/weihu' + (getLanguageCode()) + '.png',
                            width: 50,
                            height: 50,
                          ),
                      ],
                    ),
                  ),
                  const SizedBox(width: 10),
                  Expanded(
                    child: Column(
                      mainAxisAlignment: MainAxisAlignment.center,
                      crossAxisAlignment: CrossAxisAlignment.start,
                      children: [
                        Row(
                          mainAxisAlignment: MainAxisAlignment.start,
                          crossAxisAlignment: CrossAxisAlignment.center,
                          children: [
                            Flexible(
                              child: Text(
                                model.name,
                                style: const TextStyle(
                                  fontSize: 15,
                                  color: Color(0xFF333333),
                                ),
                                maxLines: 2,
                              ),
                            ),
                            if (model.shopPaymentId == 56)
                              GestureDetector(
                                onTap: onShowAuthTips,
                                child: Padding(
                                  padding: const EdgeInsets.only(left: 5),
                                  child: Image.asset(
                                    'assets/images/howinfo.png',
                                    width: 16,
                                    height: 16,
                                  ),
                                ),
                              ),
                          ],
                        ),
                        if (showAuthTips)
                          GestureDetector(
                            behavior: HitTestBehavior.opaque,
                            onTap: onShowAuthTips,
                            child: Padding(
                              padding: const EdgeInsets.only(top: 3),
                              child: Container(
                                padding: const EdgeInsets.symmetric(vertical: 2, horizontal: 2),
                                decoration: BoxDecoration(
                                  color: const Color(0xFFF3F3FF),
                                  borderRadius: BorderRadius.circular(5),
                                ),
                                child: Text(
                                  AppLocalizations.of(context)!.howtor,
                                  style: TextStyle(
                                    fontSize: 12,
                                    color: Color(0xFF5D5FEE),
                                  ),
                                ),
                              ),
                            ),
                          ),
                      ],
                    ),
                  ),
                  if (model.status != 2)
                  Image.asset(
                    isSelected ? 'assets/images/login_select.png' : 'assets/images/login_unselect.png',
                    width: 22,
                    height: 22,
                  ),
                ],
              ),
            ),
            const Divider(
              height: 1,
              indent: 15,
              endIndent: 15,
              color: Color(0xFFF6F6F6),
            ),
          ],
        ),
      ),
    );
  }
}
